package com.beiyou.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.hutool.core.bean.BeanUtil;
import com.beiyou.dto.PurchaseMasterQueryDto;
import com.beiyou.dto.PurchaseMasterDto;
import com.beiyou.dao.PurchaseMasterMapper;
import com.beiyou.entity.PurchaseMasterEntity;
import java.util.List;

/**
 *
 * @author wzby
 * @date 2022-11-01 15:05:44
 */
@Service
public class PurchaseMasterService {

    @Autowired
    private PurchaseMasterMapper purchaseMasterMapper;

    public Integer insert(PurchaseMasterDto dto){
        //业务判断逻辑
        PurchaseMasterEntity entity = BeanUtil.copyProperties(dto, PurchaseMasterEntity.class);
        return purchaseMasterMapper.insert(entity);
    }

    public Integer update(PurchaseMasterDto dto){
            PurchaseMasterEntity entity = BeanUtil.copyProperties(dto, PurchaseMasterEntity.class);
        return purchaseMasterMapper.update(entity);
    }

    public List<PurchaseMasterDto> select(PurchaseMasterQueryDto dto){
        List<PurchaseMasterEntity> entities = purchaseMasterMapper.select(dto);
        return BeanUtil.copyToList(entities, PurchaseMasterDto.class);
    }

    public Integer delete(Integer id){
        return purchaseMasterMapper.delete(id);
    }

}
